﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using System.Xml;


public static class Params
{
    public static Vector3 camPos;
    public static Vector2 blur;
    public static Vector2 windowSize;
    public static Vector2 bufferSize;
    public static Vector2 previewSize;
    public static Vector4 clipPlaneGround;
    public static int fboSamples;

    public static int gridRenderMode;
    public static int polygonMode;

    public static bool applyShadow;
    public static bool renderMesh;
    public static bool renderObjects;
    public static bool renderTextures;
    public static bool renderWireframe;
    public static bool renderNormals;
    public static bool renderMisc;
    public static bool applyCulling;
    public static bool sceneDistances;
    public static bool renderObjectBB;

    public static Vector2 shadowMapSize;

    public static float shadowIntensity;
    public static float depthRangeMax;
    public static float depthRangeMin;
    public static float polygonOffsetFactor;
    public static float polygonOffsetUnits;
    public static float ncp;
    public static float fcp;
    public static float fov;
    public static float ncpLight;
    public static float fcpLight;
    public static float fovLight;
    public static float sampleShading;
    public static float lightIntensity;

    public static Vector3 globalSceneViewScale;
    public static double globalSceneUnitScale;  // unit in file to m

    public static List<Light> lights = new List<Light>();
    public static int activeLight;

    public static int nrVertices;
    public static int nrActiveVertices;

    public static string modelDirectory;
    public static string textureDirectory;
    public static string sceneDirectory;
    public static string localSceneDBDirectory;
    public static string shapeNetSemDirectory;

    public static int previewNum;
    public static bool isUseContext;
    public static bool showBothOriginAndContextView;
    public static int addContextSceneNum;

    public static bool addSynthNode;
    public static int addSynthSceneNum;

    public static string sceneDBType;
    public static string selectMethod;
    public static double contextCoOccProb;
    public static double groupOccProb;
    public static bool doVideo;

    public static Dictionary<string, Texture> textures = new Dictionary<string, Texture>();

    //public static BoundingBox sceneBB;
    public static Vector3 cameraTrans;

    public static string currentText;
    public static float textCoolDown;

    public static string relationModelPath;
    public static string resultDirectory;

    public static string attributeListpth;


    // NSM
    public static string unityModelPath;
    public static string bonesMapPath;

    public static string interfaceFile;
    
    public static string ssg_pth;
    public static string ssgList_pth;


    static Params()
    {
        // Load profile
        XmlDocument doc = new XmlDocument();
        doc.Load("params.xml");
        XmlNodeList nodeList = doc.SelectNodes("//params");
        Debug.Log(nodeList.Count);
        foreach (XmlNode node in nodeList)
        {

            interfaceFile = node.SelectSingleNode("interfaceFile").InnerText;
            
            // Action
            unityModelPath = node.SelectSingleNode("unityModelPath").InnerText;
            bonesMapPath = node.SelectSingleNode("bonesMapPath").InnerText;

            // LDS
            attributeListpth = node.SelectSingleNode("attributeListpth").InnerText;

            relationModelPath = node.SelectSingleNode("model_pth").InnerText;
            localSceneDBDirectory = node.SelectSingleNode("sceneDB_pth").InnerText;
            resultDirectory = node.SelectSingleNode("result_pth").InnerText;
            sceneDirectory = node.SelectSingleNode("scenedir").InnerText;
            modelDirectory = node.SelectSingleNode("modledir").InnerText;
            textureDirectory = node.SelectSingleNode("textturedir").InnerText;
            sceneDBType = node.SelectSingleNode("scenedbtype").InnerText;
            previewNum = int.Parse(node.SelectSingleNode("previewNum").InnerText);
            addSynthNode = bool.Parse(node.SelectSingleNode("addSynthNode").InnerText);
            addSynthSceneNum = int.Parse(node.SelectSingleNode("addSynthSceneNum").InnerText);
            isUseContext = bool.Parse(node.SelectSingleNode("isUseContext").InnerText);
            addContextSceneNum = int.Parse(node.SelectSingleNode("addContextSceneNum").InnerText);
            showBothOriginAndContextView = bool.Parse(node.SelectSingleNode("showBothOriginAndContextView").InnerText);
            contextCoOccProb = double.Parse(node.SelectSingleNode("contextCoOccProb").InnerText);
            groupOccProb = double.Parse(node.SelectSingleNode("groupOccProb").InnerText);
            selectMethod = node.SelectSingleNode("selectMethod").InnerText;
            doVideo = bool.Parse(node.SelectSingleNode("doVideo").InnerText);
            globalSceneUnitScale = double.Parse(node.SelectSingleNode("globalSceneUnitScale").InnerText);

            ssg_pth = node.SelectSingleNode("ssg_pth").InnerText;
            ssgList_pth = node.SelectSingleNode("ssgList_pth").InnerText;

        }

    }
}
